<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta content="width=device-width, initial-scale=1.0, user-scalable=no" name="viewport">
    <title>登录</title>
    <meta content="" name="keywords">
    <meta content="" name="description">
    <script src="js/rem.js"></script>
    <script src="js/jquery.min.js" type="text/javascript"></script>
    <link href="css/base.css" rel="stylesheet" type="text/css"/>
    <link href="css/page.css" rel="stylesheet" type="text/css"/>
    <link href="css/all.css" rel="stylesheet" type="text/css"/>
    <link href="css/mui.min.css" rel="stylesheet" type="text/css"/>
    <link href="css/loaders.min.css" rel="stylesheet" type="text/css"/>
    <link href="css/loading.css" rel="stylesheet" type="text/css"/>
    <link href="slick/slick.css" rel="stylesheet" type="text/css"/>
</head>
<!--loading页开始-->
<div class="loading">
    <div class="loader">
        <div class="loader-inner pacman">
            <div></div>
            <div></div>
            <div></div>
            <div></div>
            <div></div>
        </div>
    </div>
</div>
<!--loading页结束-->
<body>
<div class="login clearfloat box-s">
    <h3>会员登录</h3>
    <div class="list clearfloat">
        <ul>
            <li class="ra3">
                <p class="fl clearfloat">
                    <span class="opa5"></span>
                    <i class="iconfont icon-yonghuming"></i>
                </p>
                <div class="nr clearfloat fl">
                    <span class="opa3"></span>
                    <input id="account" placeholder="登陆账号" type="text" value=""/>
                </div>
            </li>
            <li class="ra3">
                <p class="fl clearfloat">
                    <span class="opa5"></span>
                    <i class="iconfont icon-mima"></i>
                </p>
                <div class="nr clearfloat fl">
                    <span class="opa3"></span>
                    <input id="password" placeholder="登录密码" type="text" value=""/>
                </div>
            </li>
        </ul>
    </div>
    <div class="mima clearfloat">
        <ul>
            <li class="fl">
                <div class="xuan clearfloat fl">
                    <div class="radiofour">
                        <label>
                            <input id="isRemember" type="checkbox"/>
                            <div class="option"></div>
                            <span class="opt-text">记住密码</span>
                        </label>
                    </div>
                </div>
            </li>
            <li class="fr">
                <a href="verification.html">找回密码？</a>
            </li>
        </ul>
    </div>
    <div class="login-btn" onclick="login()">
        <a>
            登录
        </a>
        <a class="btn" href="register.html">
            <span class="opa5"></span>
            <samp>注册</samp>
        </a>
    </div>
</div>
</body>
<script type="text/javascript">
    $(window).load(function () {
        let loading = $(".loading")
        loading.addClass("loader-chanage");
        loading.fadeOut(300)
    });

    function login() {
        let account = $('#account').val();
        let password = $('#password').val();
        let isRemember = $('#isRemember').val();
        $.ajax({
            url: 'api/user/login',
            type: 'POST',
            data: {
                account: account,
                password: password,
                isRemember: isRemember
            },
            success: function (result, textStatus, request) {
                if (result.code === 1) {
                    let accessTokenKet = "AccessToken";
                    let accessToken = request.getResponseHeader(accessTokenKet);
                    window.localStorage.setItem(accessTokenKet, accessToken);
                    location.replace('center.html');
                } else {
                    alert(result.msg);
                }
            }
        })
    }
</script>
</html>
